home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / raid / devRaidLog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  2.2 KB  |  74 lines

  1. /* 
  2.  * devRaidLog.h --
  3.  *
  4.  *    Implements logging and recovery for raid devices.
  5.  *
  6.  * Copyright 1990 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef _DEVRAIDLOG
  17. #define _DEVRAIDLOG
  18.  
  19. #include "sync.h"
  20. #include <sprite.h>
  21. #include "devRaid.h"
  22. #include "miscutil.h"
  23.  
  24. #define RAID_LOG_BUF_SIZE    1000
  25.  
  26. /*
  27.  * Location and size of log offsets on the log disk for configuration info,
  28.  * disk state and parity-stripe state.
  29.  */
  30.  
  31. /*
  32.  * Minimum unit of log update.
  33.  * The minumum unit of log update must be at least 8 words (32 bytes).
  34.  */
  35. #define MinUpdateSize(raidPtr)    \
  36.     (MAX(32, (raidPtr)->log.logHandlePtr->minTransferUnit))
  37. #define RoundToUpdateSize(raidPtr, bytes)    \
  38.     (RoundUp(bytes, (raidPtr)->log.logHandlePtr->minTransferUnit))
  39.  
  40. #define ParamSize(raidPtr)    (MinUpdateSize(raidPtr))
  41. #define ParamLoc(raidPtr)    ((raidPtr)->log.logDevOffset)
  42.  
  43. #define DiskID(raidPtr, col, row)    ((col)*(raidPtr)->numRow+(row))
  44. #define DiskSize(raidPtr)    \
  45.     (MinUpdateSize(raidPtr)*((raidPtr)->numCol)*((raidPtr)->numRow))
  46. #define DiskLoc(raidPtr, col, row)    \
  47.     ((raidPtr)->log.logDevOffset + ParamSize(raidPtr) +    \
  48.         MinUpdateSize(raidPtr)*DiskID(raidPtr, col, row))
  49.  
  50. #define VecSize(raidPtr)    \
  51.     (RoundToUpdateSize(raidPtr, Bit_NumBytes((raidPtr)->numStripe)))
  52. #define VecLoc(raidPtr)        \
  53.     ((raidPtr)->log.logDevOffset + ParamSize(raidPtr) + DiskSize(raidPtr))
  54.  
  55. #define LogSize(raidPtr)    \
  56.     (ParamSize(raidPtr) + DiskSize(raidPtr) + VecSize(raidPtr))
  57.  
  58. typedef struct {
  59.     Sync_Semaphore     mutex;
  60.     int             enabled;
  61.     int             busy;
  62.     Fs_Device         logDev;
  63.     int             logDevOffset;
  64.     int             logDevEndOffset;
  65.     DevBlockDeviceHandle *logHandlePtr;
  66.     int            *diskLockVec;    /* disk image of locked stripes */
  67.     int            *lockVec;    /* actually locked stripes */
  68.                     /* the disk image is unlocked lazily */
  69.     int             numStripeLocked;
  70.     Sync_Condition       flushed;
  71. } RaidLog;
  72.  
  73. #endif /* _DEVRAIDLOG */
  74.